home *** CD-ROM | disk | FTP | other *** search
/ Amiga Mag HDD Backup / Amiga Mag HDD Backup.zip / Amiga Mag HDD Backup / Alexander.img.bin / Alexander.img / 315 2 files Archive.sit / Any plain-text files / ? Any plain-text file 77 < prev    next >
Text File  |  1995-01-03  |  15KB  |  275 lines

  1. eDevice((struct IORequest*)usrIO);
  2.  
  3. allDone:
  4.  
  5.    if( usrIO )
  6.       DeleteIORequest(usrIO);
  7.  
  8.    if( usrPort )
  9.       DeleteMsgPort(usrPort);      
  10.  
  11.    exit(0);
  12. }
  13. ke file places 
  14.  
  15. the user.device module in your DEVS: directory, which is the 
  16.  
  17. Amiga's standard device directory.
  18.  
  19.  
  20. Next, compile and link the "tstUserDev" and "devTrace" 
  21.  
  22. programs.  This is done by typing "sc link tstUserDev" and 
  23.  
  24. "sc link devTrace" in the directory where the tstUserDev.c 
  25.  
  26. and devTrace.c files are located.  
  27.  
  28.  
  29. You run the test program by typing "tstUserDev".  However, 
  30.  
  31. this program does not let you know what command it is 
  32.  
  33. sending to the device, or what kind of reply the device is 
  34.  
  35. sending back.  It simply loops, sending all the commands the 
  36.  
  37. device recognizes to it, prints any error code returned by 
  38.  
  39. the device, and quits.  You can add print statements to the 
  40.  
  41. program to see what it is doing.  
  42.  
  43.  
  44. To see what kind of commands the device is receiving, you 
  45.  
  46. can turn on the device's debug output.  This is done by 
  47.  
  48. running the devTrace program in its own shell window.  Run 
  49.  
  50. the program by typing "devTrace user.device".  From another 
  51.  
  52. shell window, run the tstUserDev program.  The device will 
  53.  
  54. write trace-style output in the shell window where the 
  55.  
  56. devTrace program is running.  To end the devTrace program, 
  57.  
  58. type the 'control-c' key combination in the shell window 
  59.  
  60. where the devTrace program is running.  When you run the 
  61.  
  62. tstUserDev program while the devTrace program is running, it 
  63.  
  64. will receive two error return values from the user.device 
  65.  
  66. when it attempts to turn device debug on and off, since the 
  67.  
  68. device will accept debug commands from only one program at a 
  69.  
  70. time.  The error codes are -8 and -9.  Macros for these 
  71.  
  72. error codes are in devinit.h.  They indicate that the user 
  73.  
  74. device is already processing debug (DEVERR_DBGBUSY), and 
  75.  
  76. that the file handle sent in the command to turn off debug 
  77.  
  78. output does not match the file handle used to turn on debug 
  79.  
  80. output (DEVERR_BADFH).      
  81.  
  82.  
  83.                    [ Figure 3 near here ]
  84.  
  85.  
  86. BUILDING YOUR OWN DEVICE
  87.  
  88.  
  89. You can experiment with the code by creating a "test" device 
  90.  
  91. and adding code to the procedures in userdev.c that 
  92.  
  93. implement the device's commands.  To do this, create a 
  94.  
  95. directory for the test device, copy the files into the 
  96.  
  97. directory, then rename the userdev.c, userdev.h and 
  98.  
  99. userdev.make files as testdev.c testdev.h, and testdev.make.
  100.  
  101.  
  102. Next, edit the testdev.h file and change all occurrences of 
  103.  
  104. "user" to "test", and all occurrences of "USER" to "TEST".  
  105.  
  106. This changes the name of the device in the name macro 
  107.  
  108. (DEV_NAME) and the id string macro (DEV_IDSTR).  Edit the 
  109.  
  110. testdev.c file, again changing "user" to "test".  Don't 
  111.  
  112. rename the "usr_xxx" procedures in this file, since the code 
  113.  
  114. in devinit.c calls them.  They do not need to be renamed, 
  115.  
  116. since they are not visible outside their device.  Now edit 
  117.  
  118. the testdev.make file and change all occurrences of "user" 
  119.  
  120. to "test".  After you edit these three files, you are ready 
  121.  
  122. to build your device.  Type "smake -f testdev.make" to build 
  123.  
  124. the device.  When the link finishes, you should have a 
  125.  
  126. device named "test.device" in your DEVS: directory.  
  127.  
  128.  
  129. To test the test.device, copy tstUserDev.c to tstTestDev.c 
  130.  
  131. and modify the code, changing "user.device" to 
  132.  
  133. "test.device".  You can then try out your new device, 
  134.  
  135. including using the devTrace program to trace its execution.    
  136.  
  137. After you have the device running, add trace output to the 
  138.  
  139. procedures in testdev.c and/or actual code to implement the 
  140.  
  141. functionality ofa/*=======================================================*/
  142. /*
  143.  *  Listing 5.  userdev.c - user-defined device functions
  144.  *
  145.  *  This file contains 'skeleton' procedures for a
  146.  *  device.  These procedures are called from procedures
  147.  *  in devinit.c.  They are 'fleshed out' to implement
  148.  *  the functionality for an actual device.
  149.  *
  150.  *  Placed in the Public Domain by Forest W. Arnold, 1994
  151. */
  152. /*=======================================================*/
  153.  
  154. #include "userdev.h"
  155.  
  156. /*
  157.  *  define the device name an MusicX-Magic.txt is an article about using the ARexx port of Music-X 2.0
  158. to customize the program.  The "Pictures" directory contains two IFF
  159. graphics that accompany the article.
  160.  
  161.     Daniel J. Barrett
  162.     62 Summer Street, Apt 1
  163.     Amherst, MA  01002-1122
  164.                         
  165.     (413) 549-7157
  166.  
  167.     barrett@cs.umass.edu
  168. c procedures called from 
  169.  *  the procedures in this file
  170. */
  171.  
  172. int cmd_Invalid( struct IOStdReq * );
  173. int cmd_Reset( struct IOStdReq * ); 
  174. int cmd_Read( struct IOStdReq * );  
  175. int cmd_Write( struct IOStdReq * ); 
  176. int P.O. Box 1933
  177. Ozona, TX 76943
  178.  
  179. A Tale of Two Dos's: Part II
  180.  
  181.  
  182. Last month I began an examination of AmigaDOS and MS-DOS. As I continue that examination, I would like to turn to several common commands used by both systems: DIR, COPY, DELETE, MAKEDIR, RENAME, and CD. I will examine the syntax of the commands for both systems, and I will assume that you are familiar with syntax structure. I will then point out the differences that exist.
  183. I don't know about you, but the command I use most is DIR, so let's begin with it. For AmigaDOS, the syntax is
  184.  
  185. DIR [<dir|pattern>] [OPT A|I|AI|D|F] [ALL] [DIRS] [FILES]
  186. [INTER]
  187.  
  188.  
  189. Basically, AmigaDOS will list all of the contents of a directory, both files and subdirectories, using this command. The directories will be listed first, in random order, followed by the files, listed in alphabetical order. The options allow you to display all subdirectories and their files [ALL option], display only directories [DIRS option], display only files [FILES option], and to enter an interactive listing mode [INTER option]. The interactive listing takes you into each directory and subdirectory and allows you to act upon files as you go.
  190. When you execute DIR from the MS-DOS prompt, all files and directories within the current directory are listed in what appears to me to be random order. There is no separation into files or directories, and items are not alphabetized. Although the syntax for DIR in MS-DOS is fairly long, I want to show it below:
  191.  
  192. DIR [drive:][path][filename] [/P][/W][/A[[:]attributes]]
  193. [/O[[:]sortorder]] [/S][/B][/L]
  194.  
  195. [drive:][path][filename]
  196. specifies drive, directory, and/or files to list.
  197. /PPauses after each screenful of information.
  198. /WUses wide list format.
  199. /ADisplays files with specified attributes.
  200. attributesD  DirectoriesR  Read-only files
  201. H  Hidden filesA  Files ready for
  202.  archiving
  203. S  System files-  Prefix meaning
  204.  "not"
  205. /OList by files in sorted order.
  206. sortorderN  By name S  By size (small-
  207.    (alphabetic)   est first.
  208. E  By extensionD By date & tiime
  209.    (alphabetic)   (earliest first)
  210. G  Group direct--  Prefix to reverse
  211.    ories first   order.
  212. /SDisplays files in specified directory and all
  213. subdirectories.
  214. /BUses bare format (no heading information or summary).
  215. /LUses lowercase.
  216.  
  217. Switches may be preset in the DIRCMD environment variable.
  218. Override preset switches by prefixing any switch with -
  219. (hyphen) -- for example, /-W.
  220.  
  221.  
  222. That is certainly a mouthful. Really, for what each does, AmigaDOS (A-DOS henceforth) DIR does about the same that MS-DOS does. Since A-DOS already alphabetizes its files, there is no need to summon a switch to do so as you must with MS-DOS. When I use MS-DOS, I always add the /O switch to order things unless I know that the directory I am looking at is fairly small. I don't have to do this with A-DOS. But MS-DOS does allow you to list files by date and size order, and I must admit that I like that very much. And, although not part of the DIR command, MS-DOS does allow you to "hide" files (make them invisible) while allowing you to list them with a DIR switch. Of course, this is only good if others sharing your machine are not very computer literate. And one more thing I like about MS-DOS is the /p switch, which causes the listing to pause at the end of each screen.
  223. As far as ease of use, the A-DOS version is better because you do not have to summon any options to separate files from directories. Also, the interactive mode is superb, especially when you are cleaning old files from your disk or doing other maintainence type work. I used this option extensively in the very first article I ever wrote for this magazine. That article concerned stripping down your boot disk, and this option allowed me to enter each directory/subdirectory and delete any files that were not absolutely necessary. An option to allow you to sort files and directories by date and size would certainly be a nice addition, though.
  224. The next command I want to examine is COPY. For A-DOS the syntax is 
  225.  
  226. COPY [FROM] {<name|pattern>} [TO] <name|pattern> [ALL] [QUIET]
  227. [BUF|BUFFER = <n>] [CLONE] [DATES] [NOPRO] [COM] [NOREQ}
  228.  
  229.  
  230. By using the ALL option, you can copy all subdirectories as well as files within a directory. The other options perform other little tasks not normally needed.
  231. The MS-DOS version of COPY has the following syntax:
  232.  
  233. COPY [/A | /B] source [/A | /B] [+ source [/A | /B]
  234. [+ ...]] [destination [/A \ /B]] [/V]
  235.  
  236. sourceSpecifies the file or files to be
  237. copies.
  238. /AIndicates an ASCII text file.
  239. /BIndicates a binary file.
  240. destination file(s)Specifies the directory and/or 
  241. filename for the new file(s).
  242. /VVerifies that new files are written
  243. correctly.
  244.  
  245. To append files, specify a single file for destination, but
  246. multiple files for source (using wildcards or file1+file2+
  247. file3 format).
  248.  
  249.  
  250. MS-DOS copy does about the same as A-DOS copy. It has a shortcoming, though. It will not copy subdirectories and their contents. To do this in MS-DOS, you must use another command called XCOPY (along with a couple of switches). However, you can combine files using COPY in MS-DOS, something you cannot do with the A-DOS version. In A-DOS, you use the JOIN command to accomplish this. 
  251. Now, how do we stand? As regards DIR, I prefer A-DOS when used in its bare form. However, with all the switches available in the MS-DOS version, it has more power overall. As regards the COPY command, A-DOS once again is my favorite in its bare form. However, the ability to combine files gives the MS-DOS version a slight advantage for those who need that option. 
  252. One more thing before closing for this month. Since I do normally use my Amiga more (it's at home), I am more comfortable with it. I tend to forget the syntax of MS-DOS commands, especially since when I do use an MS-DOS machine, I stay within Windows as much as possible. One thing I like about MS-DOS, though, is the complete syntax provided with the commands. You simply type the command in question, skip a space, then type "/?" and you receive a very detailed syntax, as illustrated in the two commands given above. In A-DOS, a cryptic looking template appears that remains a mystery except for experienced users. Such a thorough syntax would probably be quite helpful on Amigas for newcomers. 
  253. Next month, we will cover the remaining commands.
  254.  as that.  What about Daylight Savings Time?  What about Daylight Time in Australia?  Aren't their seasons reversed from ours?  Does your long distance carrier have discount rates to foreign countries?  They usually put in a few discount hours that coincide with a few business hours where you are calling.  Our programs will address these questions.  If you don't have a mate in Sydney, Australia, or don't live in my time zone, the program is easily adapted for anywhere else in the world.  As an exercise, you may want to dress up the program so that there is opportunity for the user to input any locale (such as large cities around the world) and let the program take care of everything else.
  255.  
  256. The Computations
  257. Prefs/Locale shows that MST is offset 7 hours from GMT.  Sydney, Australia is 10 hours ahead of GMT.  In summer, Mountain Daylight Time puts the clock ahead one hour, reducing the local time offset to 6 hours behind GMT.  For Daylight Savings Time move your locale offset number one hour to the right (east) and going back to regular time use the given number (Spring Ahead, Fall Back).  Moving to the right will decrease your offset if you are west of GMT and increase it if you are east of GMT.  The International Date Line divides "east" from "west" (see below).  Thus MST is 7 hours and MDT is 6 hours behind GMT.  Sydney's standard (winter) time is GMT plus 10.  Since they are having WINTER when we are having summer (and daylight time), the proper calculation for Sydney is 16 hours ahead of MDT (Daylight time).  In winter, MST is 7 hours behind GMT, but Sydney has moved into SUMMER down under and their offset moves to the right one hour (11 hours ahead of GMT).  So in my winter, I must add 18 hours to my time to get the local time in Sydney.  For destinations in the Northern Hemisphere, of course you do not need to change offsets as they will be in step year round.
  258.  
  259. What Day Is It?
  260. In the Pacific Ocean east of New Zealand is the International Date Line, a line along 180 degrees longitude, except where it veers so as not to bisect countries.  Just to the west of the line, time is deemed to be 12 hours ahead of GMT and just to the east of the line time is 12 hours behind GMT.  In other words, the date changes abruptly from Monday east of the line to Tuesday west of it.  (Flying back from Sydney, you arrive in Los Angeles two hours before you left Sydney!)  The program needs to figure the day as well.  Long distance rates may be very low on Sunday but you can make a Sunday business call across the Date Line to Monday in the Pacific Rim.  The program should allow for that possibility.  Conversely, if you dial across the Date Line on a Friday to a Saturday, or on a Saturday to a Sunday, you run an increasing risk of a business being closed.  The program should also be adaptable to personal calls, so we will make computing business hours a user specified option.
  261.  
  262. AUSTIME.REXX
  263. This program allows the user to choose System time (by pressing [Enter] at the prompt), or to input an hour in HH format.  I chose to use Military or 24 hour time to eliminate AM and PM.  After you input a time here, the program displays a line telling you what time you chose here and what time/day that corresponds to in Sydney.  If you enter your own hour, HH, then the program will display "today" for here and either "today" or "tomorrow" for Sydney, depending on the input hour.  If you input 0 or 24, the program will display "midnight" here and "same day" for Sydney.  If you choose System time by entering a null string, the program will display hours minutes and seconds, and the actual day here, such as "Wednesday", but other output is the same.
  264.  
  265. The first thing after the obligatory comment is the use of the DATE() function without arguments.  This returns a string in the form:
  266.  
  267. DD MMM YYYY 
  268.  
  269. The default for the DATE() function is as if a NORMAL argument had been specified (e.g. it returns a sFORM??*?FTXTPSET???t??????
  270. @!??????@&???????ê???????ê???????????????????????ê???????ê??????????????????????????????????????????????RULE???@??    ????????@????>????@???????????????????????????????????????PINF????????    FONS?????topaz.font??STYL?????CLR ????CHRS???P.O. Box 1933
  271. PINF????????    CHRS???Ozona, TX 76943
  272. PINF????????    CHRS???
  273. ?RULE???@??    ????????@????>????@???????????????????????????????????????PINF????????    CHRS???A Tale of Two Dos's: Part II
  274. ?PINF????????    CHRS???
  275. ?PINF????????